import java.awt.*;
import java.awt.image.*;

public class wolke {

	int wolke;
	
	
	static Point[] p;
	int width, height, v;
	BufferedImage[] bild;

	public wolke(int z, int width, int height, int v, int wolken,
			BufferedImage[] bild) {
		this.bild = bild;
		this.wolke = wolken;
		this.width = width;
		this.height = height;
		this.v = v;
		p = new Point[this.wolke];
		for (int i = 0; i < wolke; i++) {
			int r1 = (int) (Math.random() * width);
			int r2 = (int) (Math.random() * height);
			// System.err.println(r1+ " "+r2);
			p[i] = new Point(r1, r2);
		}
	}

	public void next() {
		for (int i = 0; i < wolke; i++) {
			int x = (int) p[i].getX();
			int y = (int) p[i].getY();

			// int r1=(int) (Math.random()*5)-2;
			int r2 = (int) (Math.random() * 5) - 2;
			int x1 = x - v;
			int y1 = y + r2;

			if (x1 < 0) {
				x1 = this.width;
			} else if (x > this.width) {
				x1 = 0;
			}

			if (y1 < 0) {
				y1 = this.height;
			} else if (y > this.height) {
				y1 = 0;
			}

			p[i] = new Point(x1, y1);
			// System.err.println(r);

		}
	}

	public void drawObjects(Graphics g) {

		

		for (int i = 0; i < wolke; i++) {
			if (p[i] != null) {
				// g.drawString("WOLKE",(int)p[i].getX(),(int)p[i].getY());
				g
						.drawImage(bild[0], (int) p[i].getX(), (int) p[i]
								.getY(), null);
			}

		}
		
		next();
	}
}